package ihm;

import java.awt.Dimension;

import javax.swing.ImageIcon;
import javax.swing.JButton;

import utils.Bombe;
import utils.Entity;
import utils.Tresor;
import utils.Type;

public class Case extends JButton{

	private static final long serialVersionUID = 1L;
	private Type typebloc;
	private Tresor tresor;
	private Entity entite;
	private Bombe bombe;

	public Case(Type typeCase){
		typebloc=typeCase;
		tresor = Tresor.RIEN;
		entite = Entity.PERSONNE;
		this.bombe = Bombe.RIEN;

		setPreferredSize(new Dimension(16, 16));
		setRolloverEnabled(false);
		setEnabled(true);
		updateGrapgics();
	}

	public Case(Tresor tresor) {
		this.tresor=tresor;
		typebloc=Type.VIDE;
		entite = Entity.PERSONNE;
		this.bombe = Bombe.RIEN;

		setPreferredSize(new Dimension(16, 16));
		setRolloverEnabled(false);
		setEnabled(true);
		updateGrapgics();
	}
	
		
	
	public Case(Type typebloc,Tresor tresor,Entity entite) {
		this.tresor=tresor;
		this.typebloc=typebloc;
		this.entite = entite;
		this.bombe = Bombe.RIEN;
		setPreferredSize(new Dimension(16,16));
		setRolloverEnabled(false);
		setEnabled(true);
		updateGrapgics();
	}
	
	public Case(Entity entite) {
		this.bombe = Bombe.RIEN;
		this.tresor=Tresor.RIEN;
		this.typebloc=Type.VIDE;
		this.entite = entite;

		setPreferredSize(new Dimension(16, 16));
		setRolloverEnabled(false);
		setEnabled(true);
		updateGrapgics();

	}

	public Case(Bombe bombe) {
		this.bombe = bombe;
		this.tresor=Tresor.RIEN;
		this.typebloc=Type.VIDE;
		this.entite = Entity.PERSONNE;

		setPreferredSize(new Dimension(16, 16));
		setRolloverEnabled(false);
		setEnabled(true);
		updateGrapgics();
	}

	public void setBloc(Type newTypeCase){
		typebloc=newTypeCase;
		updateGrapgics();
	}
	public Type getBloc(){
		return typebloc;
	}

	private void updateGrapgics() {
		switch (typebloc){
		case VIDE:
			setIcon(new ImageIcon(""));
			break;
		case MURBRIQUE:
			setIcon(new ImageIcon("murbrique.png"));
			break;
		case MURMETAL:
			setIcon(new ImageIcon("murmetal.png"));
			break;
		default :
			break;
		}

		switch(tresor){
		case BOMBUP:
			setIcon(new ImageIcon("bombup.png"));
			break;
		case BOMBPASS:
			setIcon(new ImageIcon("bombpass.png"));
			break;
		case FIREUP:
			setIcon(new ImageIcon("fireup.png"));
			break;
		case FIRESUIT:
			setIcon(new ImageIcon("fireup.png"));
			break;
		case WALLPASS:
			setIcon(new ImageIcon("wallpass.png"));
			break;
		default :

		}

		switch(bombe){
		case BOMBE:
			setIcon(new ImageIcon("bombe.png"));
			break;
		case RIEN:
			break;
		default:
			break;
		}

		switch(entite){
		case BOMBERMAN:
			setIcon(new ImageIcon("bomberman.png"));
			break;
		case KIDNAPPEUR:
			setIcon(new ImageIcon("kidnappeur.png"));
			break;
		case BALLONORANGE:
			setIcon(new ImageIcon("ballonorange.png"));
			break;
		case FANTOMEBLEU:
			setIcon(new ImageIcon("fantomebleu.png"));
			break;
		default :
			break;
		}
		repaint();
	}
}